package edu.umd.ion.wavemeter.server;

public class UsernameChannel implements Comparable<UsernameChannel> {
	public String Username;
	public Integer Channel;	
	
	public UsernameChannel(String username, int channel) {
		Username = username;
		Channel = channel;
	}

	public UsernameChannel() {}
	@Override
	public int compareTo(UsernameChannel o) {
		int sc = Username.compareTo(o.Username);
		return sc!=0 ? sc : Channel.compareTo(o.Channel);
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + Channel;
		result = prime * result
		+ ((Username == null) ? 0 : Username.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UsernameChannel other = (UsernameChannel) obj;
		if (Channel != other.Channel)
			return false;
		if (Username == null) {
			if (other.Username != null)
				return false;
		} else if (!Username.equals(other.Username))
			return false;
		return true;
	}
}
